#include <stdafx.h>
#include "ReflectionShader.h"

int ReflectionShader::Init(char * fileVertexShader, char * fileFragmentShader)
{
	vertexShader = esLoadShader(GL_VERTEX_SHADER, fileVertexShader);

	if ( vertexShader == 0 )
		return -1;

	fragmentShader = esLoadShader(GL_FRAGMENT_SHADER, fileFragmentShader);

	if ( fragmentShader == 0 )
	{
		glDeleteShader( vertexShader );
		return -2;
	}

	program = esLoadProgram(vertexShader, fragmentShader);

	//finding location of uniforms / attributes
	VertPosition = glGetAttribLocation(program, "VertPosition");
	VertNorm = glGetAttribLocation(program, "VertNorm");
	WVPMatrix = glGetUniformLocation(program, "WVPMatrix");
	WMatrix = glGetUniformLocation(program, "WMatrix");
	CameraPosition = glGetUniformLocation(program, "CameraPosition");
	Texture = glGetUniformLocation(program, "Texture");

	return 0;
}

ReflectionShader::~ReflectionShader()
{
	glDeleteProgram(program);
	glDeleteShader(vertexShader);
	glDeleteShader(fragmentShader);
}